﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    mc:Ignorable="d">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Values.xaml" />
        <ResourceDictionary Source="ErrorTemplate.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type DatePickerTextBox}">

        <Setter Property="Foreground" Value="{StaticResource View.Foreground.Normal}" />

        <Setter Property="Background" Value="{StaticResource View.Background}" />

        <Setter Property="BorderBrush" Value="{StaticResource Control.BorderBrush.Normal}" />

        <Setter Property="BorderThickness" Value="{StaticResource View.Border.Thickness}" />

        <Setter Property="Padding" Value="0" />

        <Setter Property="VerticalContentAlignment" Value="Center" />

        <Setter Property="HorizontalContentAlignment" Value="Stretch" />

        <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />

        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DatePickerTextBox}">

                    <Border x:Name="Border"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}">
                        <Border.CornerRadius>
                            <CornerRadius BottomLeft="{StaticResource Control.Border.CornerRadius.Value}"
                                          BottomRight="0"
                                          TopLeft="{StaticResource Control.Border.CornerRadius.Value}"
                                          TopRight="0" />
                        </Border.CornerRadius>

                        <Grid x:Name="WatermarkContent"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}">

                            <!--
                                <Border x:Name="ContentElement"
                                BorderThickness="{TemplateBinding BorderThickness}" />
                            -->

                            <!--  bb #FF45D6FA  -->
                            <!--
                                <Border x:Name="FocusVisual"
                                BorderBrush="#FF00FF94"
                                CornerRadius="{StaticResource Control.Border.CornerRadius}"
                                IsHitTestVisible="False"
                                Opacity="1" />
                            -->
                            <!--
                                <Border x:Name="watermark_decorator"
                                BorderThickness="{TemplateBinding BorderThickness}">
                            -->
                            <ContentControl x:Name="PART_Watermark"
                                            Focusable="False"
                                            IsHitTestVisible="False"
                                            Visibility="Collapsed" />
                            <!--  </Border>  -->

                            <ScrollViewer x:Name="PART_ContentHost"
                                          HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />

                        </Grid>
                    </Border>

                    <ControlTemplate.Triggers>

                        <Trigger Property="Text" Value="">
                            <Setter TargetName="PART_ContentHost" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="PART_Watermark" Property="Visibility" Value="Visible" />
                        </Trigger>

                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>

    </Style>

    <Style TargetType="{x:Type DatePicker}">

        <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ErrorTemplate}" />

        <Setter Property="OverridesDefaultStyle" Value="True" />

        <Setter Property="Foreground" Value="{StaticResource View.Foreground.Normal}" />

        <Setter Property="Background" Value="{StaticResource View.Background}" />

        <Setter Property="BorderBrush" Value="{StaticResource Control.BorderBrush.Normal}" />

        <Setter Property="BorderThickness" Value="{StaticResource View.Border.Thickness}" />

        <Setter Property="Padding" Value="3 2" />

        <Setter Property="Width" Value="130" />

        <Setter Property="IsTodayHighlighted" Value="True" />

        <Setter Property="SelectedDateFormat" Value="Short" />

        <Setter Property="HorizontalContentAlignment" Value="Center" />

        <Setter Property="HorizontalContentAlignment" Value="Center" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DatePicker}">

                    <Border x:Name="border"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="{StaticResource Control.Border.CornerRadius}">

                        <Border.Child>
                            <Grid x:Name="PART_Root">

                                <Grid.Resources>
                                    <ControlTemplate x:Key="DropDownButtonTemplate" TargetType="{x:Type Button}">
                                        <Grid>

                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="*" />
                                            </Grid.ColumnDefinitions>

                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="5*" />
                                                <RowDefinition Height="15*" />
                                            </Grid.RowDefinitions>
                                            <Border x:Name="page"
                                                    Grid.RowSpan="2"
                                                    HorizontalAlignment="Stretch"
                                                    VerticalAlignment="Stretch"
                                                    Background="{TemplateBinding Background}"
                                                    BorderBrush="{TemplateBinding BorderBrush}"
                                                    BorderThickness="1" />
                                            <Border x:Name="header"
                                                    HorizontalAlignment="Stretch"
                                                    VerticalAlignment="Stretch"
                                                    Background="{TemplateBinding BorderBrush}"
                                                    BorderBrush="{TemplateBinding BorderBrush}"
                                                    BorderThickness="1" />
                                            <TextBlock Grid.Row="1"
                                                       Grid.RowSpan="2"
                                                       Margin="0,0,0,2"
                                                       HorizontalAlignment="Center"
                                                       VerticalAlignment="Center"
                                                       FontSize="12"
                                                       FontWeight="Medium"
                                                       Text="{Binding Content,
                                                                      RelativeSource={RelativeSource TemplatedParent}}"
                                                       TextAlignment="Center" />
                                        </Grid>
                                    </ControlTemplate>
                                </Grid.Resources>

                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>

                                <Popup x:Name="PART_Popup"
                                       AllowsTransparency="True"
                                       Placement="Bottom"
                                       PlacementTarget="{Binding ElementName=border}"
                                       StaysOpen="False"
                                       VerticalOffset="-3" />

                                <!--  </Grid>  -->

                                <DatePickerTextBox x:Name="PART_TextBox"
                                                   Grid.Column="0"
                                                   Margin="{TemplateBinding Padding}"
                                                   HorizontalAlignment="Stretch"
                                                   VerticalAlignment="Center"
                                                   HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                   VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                   BorderThickness="0"
                                                   Focusable="{TemplateBinding Focusable}"
                                                   Foreground="{TemplateBinding Foreground}" />

                                <!--
                                    <Grid x:Name="PART_DisabledVisual"
                                    Grid.ColumnSpan="2"
                                    IsHitTestVisible="False"
                                    Opacity="0">

                                    <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>

                                    <Rectangle Grid.Row="0"
                                    Grid.Column="0"
                                    Fill="#A5FFFFFF"
                                    RadiusX="1"
                                    RadiusY="1" />

                                    <Rectangle Grid.Row="0"
                                    Grid.Column="1"
                                    Width="19"
                                    Height="18"
                                    Margin="3,0,3,0"
                                    Fill="#A5FFFFFF"
                                    RadiusX="1"
                                    RadiusY="1" />
                                -->

                                <Button x:Name="PART_Button"
                                        Grid.Column="1"
                                        Width="{TemplateBinding ActualHeight}"
                                        Height="{TemplateBinding ActualHeight}"
                                        Margin="0,-1,-1,-1"
                                        HorizontalAlignment="Stretch"
                                        VerticalAlignment="Stretch"
                                        Background="{TemplateBinding Background}"
                                        BorderBrush="{TemplateBinding BorderBrush}"
                                        Content="15"
                                        Focusable="False"
                                        Foreground="{TemplateBinding Foreground}"
                                        Template="{StaticResource DropDownButtonTemplate}" />

                            </Grid>
                        </Border.Child>

                    </Border>

                </ControlTemplate>
            </Setter.Value>
        </Setter>

        <Style.Triggers>

            <Trigger Property="IsEnabled" Value="false">
                <!--
                    <Setter Property="Background"
                    Value="{StaticResource Button.Background.Disabled}" />
                -->
                <Setter Property="BorderBrush" Value="{StaticResource Control.BorderBrush.Disabled}" />
                <Setter Property="Foreground" Value="{StaticResource View.Foreground.Disabled}" />
            </Trigger>

        </Style.Triggers>

    </Style>

</ResourceDictionary>